<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>果然FruitC</title>
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta http-equiv="Cache-Control" content="no-siteapp" />
		<link href="${ctx}/shop/css/amazeui.min.css" rel="stylesheet" type="text/css" />
		<link href="${ctx}/shop/css/style.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<header data-am-widget="header" class="am-header am-header-default sq-head ">
			<div class="am-header-left am-header-nav">
				<a href="${ctx}/address?type=${type}&orderid=${orderid}" class="">
					<i class="am-icon-chevron-left"></i>
				</a>
			</div>
			<h1 class="am-header-title">
  	            <a  class="">新增收货地址</a>
            </h1>
	    </header>
	    <div style="height: 60px;"></div>
	    <ul class="address">
	    	<li><input type="text" class="add-input" name="name" value="${address.name_}" placeholder="收货人" /></li>
	    	<li><input type="tel" class="add-input" name="tel" value= "${address.mobile_}"placeholder="13000000000" /></li>
	    	<li><textarea  class="add-input" style="height:80px;width:100%;" name="address" placeholder="你在哪" >${address.addr_}</textarea></li>
	    </ul>
	    <div class="moren">
	    	<label class="am-checkbox am-warning">
                 <input type="checkbox" id=def <c:if test="${def == true }">checked</c:if>  data-am-ucheck >设为默认
            </label>
	    </div>
	    <div id="error" style="height:20px;color:#9e122b;"></div>
	    <input type="button" class="login-btn" onclick= "save('${address.id}')"value="确认提交">
<script src="${ctx}/shop/js/jquery-1.10.2.min.js"></script>
<script src="${ctx}/shop/js/util.js"></script>
<script>
	function save(id){
		$(".add-input").valid({
			success : function(vals){
				$("#error").text("");
				var def = $("#def")[0];
				if(def.checked){
					vals.def = true;
				}
				sendReq("${ctx}/saveAddress?id="+id,vals,function(data){
					var text = "保存成功";
					if(!id) text = "添加成功"
					hit_box_one(text,'','','我知道啦','',function(){
						location.href = "${ctx}/address?type=${type}&orderid=${orderid}";
					});
				});
			},
			fail : function(msg){
				$("#error").text(msg);
			}
		});
	}

</script>
<%@include file="../common/jsticket.jsp"%><!--静态包含-->  
	</body>
</html>
